# Huawei Technologies Co.,Ltd.

set(HELLOWOLRD_OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/helloworld.txt)
set(HELLOWOLRD_BIN ${CMAKE_CURRENT_BINARY_DIR}/helloworld.abc)
set(HELLOWOLRD_PA ${CMAKE_CURRENT_BINARY_DIR}/helloworld.pa)
set(HELLOWOLRD_JS ${CMAKE_CURRENT_SOURCE_DIR}/helloworld.js)
set(HELLOWORLD_VERIFY ${CMAKE_CURRENT_SOURCE_DIR}/verify.sh)

set(RUNTIME_ARGUMENTS --boot-panda-files=${PANDA_BINARY_ROOT}/pandastdlib/arkstdlib.abc --load-runtimes=\"ecmascript\" --compiler-enable-jit=false ${HELLOWOLRD_BIN} _GLOBAL::func_main_0)

add_custom_command(
    OUTPUT ${HELLOWOLRD_OUTPUT}
    COMMENT "running javascript newobjdynrange testcase"
    COMMAND ${PANDA_RUN_PREFIX} $<TARGET_FILE:es2panda> ${HELLOWOLRD_JS} --dump-assembly --output ${HELLOWOLRD_BIN} > ${HELLOWOLRD_PA}
    COMMAND rm -f ${HELLOWOLRD_OUTPUT}
    COMMAND ${PANDA_RUN_PREFIX} $<TARGET_FILE:ark> ${RUNTIME_ARGUMENTS} > ${HELLOWOLRD_OUTPUT}
    COMMAND bash ${HELLOWORLD_VERIFY} ${HELLOWOLRD_OUTPUT}
)
add_custom_target(helloworld
    DEPENDS ${HELLOWOLRD_OUTPUT} ${HELLOWORLD_VERIFY}
)
add_dependencies(helloworld es2panda ark)
add_dependencies(ecmascript_common_tests helloworld)
